<template>
  <header>
    <div class="l-content">
      <el-button plain icon="el-icon-menu" size="mini" @click="handleMenu">
      </el-button>
      <!-- <span>首页</span> -->
      <el-breadcrumb separator="/">
        <el-breadcrumb-item
          v-for="item in tags"
          :to="{ path: item.path }"
          :key="item.path"
          >{{ item.label }}</el-breadcrumb-item
        >
      </el-breadcrumb>
    </div>
    <div class="r-content">
      <el-dropdown trigger="click" size="mini">
        <span>
          <img class="user" :src="userImg" alt="" />
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item>退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </header>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'CommonHeader',
  data() {
    return {
      userImg: require('@/assets/img/user.png')
    }
  },

  methods: {
    handleMenu() {
      this.$store.commit('collapseMenu')
    }

    // handleMenu(){
    //   this.$bus.$emit('handleMenu')
    // }
  },
  computed: {
    ...mapState({
      tags: (state) => state.tab.tabsList
    })
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {}
}
</script>
<style lang="less" scoped>
@theme-color: #67c23a;
@theme-color2: #f0f9eb;
header {
  display: flex;
  height: 100%;
  justify-content: space-between;
  align-items: center;
}
.l-content {
  display: flex;
  align-items: center;
  .el-button {
    &:hover {
      color: @theme-color;
      border-color: @theme-color;
    }
    &:active {
      color: @theme-color;
      border-color: @theme-color;
    }
    &:focus {
      color: @theme-color;
      border-color: @theme-color;
    }
  }
  span {
    padding-left: 12px;
    line-height: 24px;
  }
}
.r-content {
  float: right;

  .user {
    height: 48px;
    width: 48px;
    border-radius: 50%;
  }
}
.el-dropdown-menu__item {
  &:hover {
    color: @theme-color;
    background-color: @theme-color2;
  }
  &:active {
    color: @theme-color;
    background-color: @theme-color2;
  }
  &:focus {
    color: @theme-color;
    background-color: @theme-color2;
  }
}
/deep/.el-breadcrumb__inner {
  color: rgb(201, 197, 197);
}
/deep/.el-breadcrumb__item:last-child .el-breadcrumb__inner {
  color: #fff;
}
</style>
